
<?php
include_once "function_sec_nat.php";

$in_array['Name'] = $_POST['name'];
$in_array['NatType'] = $_POST['add_switch'];
$in_array['Enabled'] = $_POST['enable'];
$in_array['SrcAddr'] = $_POST['srcaddr'];
$in_array['SrcPort'] = $_POST['srcport'];
$in_array['DstAddr'] = $_POST['dstaddr'];
$in_array['DstPort'] = $_POST['dstport'];
$in_array['OutDev'] = $_POST['outdev'];
$in_array['InDev'] = $_POST['indev'];
$in_array['CvtSrcAddr'] = $_POST['cvtsrcaddr'];
$in_array['CvtDstAddr'] = $_POST['cvtdstaddr'];

$proto1 = $_POST['selPro'];
$proto2 = $_POST['protocode'];
$cvtsrcport1 = $_POST['cvtsrcport1'];
$cvtsrcport2 = $_POST['cvtsrcport2'];
$cvtdstport1 = $_POST['cvtdstport1'];
$cvtdstport2 = $_POST['cvtdstport2'];

if ($proto1 == "other")
	$in_array['Proto'] = $proto2;
else
	$in_array['Proto'] = $proto1;
	
if ( $cvtsrcport1 == "" && $cvtsrcport2 == "")
  	$in_array['CvtSrcPort'] = "nochange";
else 
{
	if ($cvtsrcport2 == "")
        	$in_array['CvtSrcPort'] = $cvtsrcport1;
	else
       		$in_array['CvtSrcPort'] = $cvtsrcport1. '-'. $cvtsrcport2;
}


if ( $cvtdstport1 == "" && $cvtdstport2 == "")
  	$in_array['CvtDstPort'] = "nochange";
else 
{
	if ($cvtdstport2 == "")
        	$in_array['CvtDstPort'] = $cvtdstport1;
	else
       		$in_array['CvtDstPort'] = $cvtdstport1. '-'. $cvtdstport2;
}

SetXmlSecOneNat($in_array);

echo("<meta http-equiv='refresh'content=0;URL='sec_policy_nat.php'>");
?>
